/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.opgea.crm.domain.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "company")
@NamedQueries({
    @NamedQuery(name = "Company.findAll", query = "SELECT c FROM Company c")})
public class Company implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "name", length = 45)
    private String name;
    @Column(name = "website", length = 45)
    private String website;
    @ManyToOne
    @JoinColumn(name = "industryType")
    private SetupsValue industryType;
    @Column(name = "companySize")
    private Integer companySize;
    @Column(name = "annualRevenue")
    private Long annualRevenue;
    
    @OneToMany(mappedBy = "company")
    private Collection<Companyphones> companyphonesCollection;
    
    @OneToMany(mappedBy = "company", cascade = CascadeType.ALL)
    private Collection<Companycompetitors> companycompetitorsCollection;
    
    @OneToMany(mappedBy = "company")
    private Collection<Lead> leadCollection;
    
    @OneToMany(mappedBy = "company", cascade = CascadeType.ALL)
    private Collection<Companyaddresses> companyaddressesCollection;
    
    @OneToMany(mappedBy = "company")
    private Collection<Employee> employeeCollection;

    
	@ManyToOne(cascade=CascadeType.REFRESH)
	@JoinColumn(name="createdBy", referencedColumnName="username")
	private CrmUser createdBy;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="createdat")
	private Date createdAt;

    public Company() {
    }

    public Company(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }

    public SetupsValue getIndustryType() {
        return industryType;
    }

    public void setIndustryType(SetupsValue industryType) {
        this.industryType = industryType;
    }

    public Integer getCompanySize() {
		return companySize;
	}

	public void setCompanySize(Integer companySize) {
		this.companySize = companySize;
	}

	public Long getAnnualRevenue() {
		return annualRevenue;
	}

	public void setAnnualRevenue(Long annualRevenue) {
		this.annualRevenue = annualRevenue;
	}

	public Collection<Companyphones> getCompanyphonesCollection() {
        return companyphonesCollection;
    }

    public void setCompanyphonesCollection(Collection<Companyphones> companyphonesCollection) {
        this.companyphonesCollection = companyphonesCollection;
    }

    public Collection<Companycompetitors> getCompanycompetitorsCollection() {
        return companycompetitorsCollection;
    }

    public void setCompanycompetitorsCollection(Collection<Companycompetitors> companycompetitorsCollection) {
        this.companycompetitorsCollection = companycompetitorsCollection;
    }

    public Collection<Lead> getLeadCollection() {
        return leadCollection;
    }

    public void setLeadCollection(Collection<Lead> leadCollection) {
        this.leadCollection = leadCollection;
    }

    public Collection<Companyaddresses> getCompanyaddressesCollection() {
        return companyaddressesCollection;
    }

    public void setCompanyaddressesCollection(Collection<Companyaddresses> companyaddressesCollection) {
        this.companyaddressesCollection = companyaddressesCollection;
    }

    /*
    public Collection<Employee> getEmployeeCollection() {
        return employeeCollection;
    }

    public void setEmployeeCollection(Collection<Employee> employeeCollection) {
        this.employeeCollection = employeeCollection;
    }*/

    public void setEmployeeCollection(Collection<Employee> employeeCollection) {
		this.employeeCollection = employeeCollection;
	}

	public Collection<Employee> getEmployeeCollection() {
		return employeeCollection;
	}

	public void setCreatedBy(CrmUser createdBy) {
		this.createdBy = createdBy;
	}

	public CrmUser getCreatedBy() {
		return createdBy;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Company)) {
            return false;
        }
        Company other = (Company) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.crm.domain.Company[id=" + id + "]";
    }

}
